package main

import "fmt"

func updateSliceValue(arr []int) {
	arr[0] = 400
}

func main() {
	// 切片 Slice 类似于Java List 但是不完全相同
	arr := [...]int{4, 6, 7, 8, 9, 10, 11}
	fmt.Println("arr=", arr)
	s1 := arr[:]
	fmt.Println("s1:", s1)
	s2 := arr[2:6]
	fmt.Println("s2:", s2)

	fmt.Println("Update After ---------->")
	updateSliceValue(s1)
	fmt.Println("update s1:", s1)
	fmt.Println("update s1 after arr:", arr)
	fmt.Println("s1 update end...........")
	updateSliceValue(s2)
	fmt.Println("update s2:", s2)
	fmt.Println("update s2 after arr:", arr)
	fmt.Println("s2 update end...........")

	fmt.Println("ReSlice-------------->")
	fmt.Println("s1:", s1)
	s1 = arr[2:5]
	fmt.Println("ReSlice 2:5", s1)
	s2 = s1[2:4]
	fmt.Println("ReSlice 2:4", s2)
	fmt.Printf("s1:%v, s1 len:%d, s1 cap len:%d \n", s1, len(s1), cap(s1))

	fmt.Println("Slice append start------------>")
	fmt.Println("arr=", arr)
	s3 := append(s2, 10)
	s4 := append(s3, 11)
	s5 := append(s4, 12)
	fmt.Println("s3, s4, s5", s3, s4, s5)
	fmt.Println("arr:", arr)

}
